export @explain macro from IMAS
#794
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary: Add Macros to track and explain Expressions
This PR introduces two new macros (
@store_exprand@explain) and related infrastructure to address the following idea from the code camp (see #786):Backend/user interace
This PR provides a way to track the chained-executions of certain expressions, which can be helpful for debugging or understanding complex dynamically defined functions.
Dependency / Related PRs
This change depends on related PRs in
IMASandIMASddpackages to fully function.Please refer to the following PR links in the related repositories:
IMASPR (Feature/explain expression IMAS.jl#224)IMASddPR (Explain the expression whenFLAG_EXPLAIN_EXPRESSION[]=trueIMASdd.jl#47)Key Changes
ExprInfostruct to store the name, arguments, and body of anonymous functions defined viadict["key"] = (args...) -> bodyassignments.@store_exprmacro:ExprInfoinexpr_info_dict.@explainmacro:IMASdd.FLAG_EXPLAIN_EXPRESSION.Examples
1. Dynamic expressions
Suppose we want to execute the some dynamic expressions under

dd.summary.volume_averageas the following:One can evaluate the expressions by typing it on the REPL, which will give the final result only.
However, to compute the final single value, the above expression actually executed multiple chained-expressions under the hood.
The new macro
@explainexplains these detailed procedures to evaluate the given dynamic expression. Note that it will also explain the chained expressions that are required to evalute the original expression.2. Onetime expressions
One can use the same
@explainmacro to see the detailed procedure for theonetimeexpression as well.Note that once the
onetimeexpression is evaluated, it is no longer an expression and has a fixed value.Hence, the subsequent call of
@explainon the sameonetimeexpression has nothing to explain.Note